
#include "stdafx.h"
#include "http_client.h"


#pragma comment(lib, "wininet")


CHttpRequest::CHttpRequest()
{

}

CHttpResponse::CHttpResponse()
{

}

CHttpClient::CHttpClient()
:m_hInternet(NULL), m_hSession(NULL)
{

}



CHttpClient::~CHttpClient()
{

}

void CHttpClient::SetProxy( CStringA const& strProxy, CStringA const& strProxyByPass)
{
	m_strProxy = strProxy;
	m_strProxyByPass = strProxyByPass;
}

BOOL CHttpClient::Create( DWORD dwAccessType, DWORD dwFlag )
{
	m_hInternet = InternetOpen( GetUserAgent(), 
		INTERNET_OPEN_TYPE_PRECONFIG, m_strProxy, m_strProxyByPass, INTERNET_FLAG_ASYNC);
	return TRUE;
}

BOOL CHttpClient::Connect( CString const& strServer, INTERNET_PORT wPort )
{
	return Connect(strServer, wPort, L"", L"", 0);
}

BOOL CHttpClient::Connect( CString const& strServer, INTERNET_PORT wPort, CString const& strUserName, CString const& strPassword, DWORD dwContext )
{
	if (NULL != m_hInternet)
	{
		CString strAnonymousUserName = L"anonymous";
		m_hSession = InternetConnect( m_hInternet, 
			strServer, wPort, strUserName, strPassword, INTERNET_SERVICE_HTTP, 0, dwContext);
		return ( NULL != m_hSession );
	}
	return FALSE;
}



BOOL CHttpClient::Get( CHttpRequest const& request, CHttpResponse& response)
{
	
	return TRUE;
}

BOOL CHttpClient::Post( CHttpRequest const& request, CHttpResponse& response)
{

	return TRUE;
}

CString CHttpClient::GetUserAgent() const
{
	return L"iRing-httpclient";
}

